﻿using RimWorld;
using System.Linq;
using Verse;

namespace RimZombieGirl
{
    public class IncidentWorker_CurseResurrection : IncidentWorker
    {
        protected override bool CanFireNowSub(IncidentParms parms)
        {
            // 只有当有地图缓存诅咒值时才允许触发
            var manager = Current.Game.GetComponent<GameComponent_CurseManager>();
            return manager != null && manager.cachedMapCurses.Count > 0;
        }

        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = parms.target as Map;
            if (map == null) return false;

            var manager = Current.Game.GetComponent<GameComponent_CurseManager>();
            if (manager == null || manager.cachedMapCurses.Count == 0) return false;

            // 执行“诅咒复苏”
            manager.ResurrectCursesToMap(map);

            Messages.Message("Curse Resurrected".Translate(), MessageTypeDefOf.ThreatBig, false);

            return true;
        }
    }
}
